Skip to content

Burachek_413_homework#13

Open
Pavel-bur-dot wants to merge 22 commits intoDafeCpp:mainfrom
Pavel-bur-dot:main
Open

Burachek_413_homework#13
Pavel-bur-dot wants to merge 22 commits intoDafeCpp:mainfrom
Pavel-bur-dot:main

Conversation

@Pavel-bur-dot
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

Comment thread task_01/src/test.cpp Outdated
#include <utility>

// Функция, которую мы тестируем
std::pair<int, int> find_sum(const std::vector<int>& nums, int target) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: function 'find_sum' can be made static or moved into an anonymous namespace to enforce internal linkage [misc-use-internal-linkage]

Suggested change
std::pair<int, int> find_sum(const std::vector<int>& nums, int target) {
мы тестируемstatic

Comment thread task_01/src/two_numbers.h Outdated
@@ -0,0 +1,5 @@
#include <vector>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: 'vector' file not found [clang-diagnostic-error]

#include <vector>
         ^

Comment thread task_02/src/stack.cpp Outdated
return result;
void Stack::display() {
if (arr.empty()) {
std::cout << "Stack is empty." << std::endl;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not use 'std::endl' with streams; use '\n' instead [performance-avoid-endl]

Suggested change
std::cout << "Stack is empty." << std::endl;
std::cout << "Stack is empty." << '\n';

Comment thread task_02/src/stack.cpp Outdated
for (int i = 0; i < arr.size(); ++i) {
std::cout << arr[i] << " ";
}
std::cout << std::endl;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not use 'std::endl' with streams; use '\n' instead [performance-avoid-endl]

Suggested change
std::cout << std::endl;
std::cout << '\n';

Comment thread task_05/src/merge_sort.h
@@ -0,0 +1,4 @@
#include <vector>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: 'vector' file not found [clang-diagnostic-error]

#include <vector>
         ^

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

Comment thread task_02/src/stack.cpp
return result;
void Stack::display() {
if (arr.empty()) {
std::cout << "Stack is empty." << std::endl;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not use 'std::endl' with streams; use '\n' instead [performance-avoid-endl]

Suggested change
std::cout << "Stack is empty." << std::endl;
std::cout << "Stack is empty." << '\n';

Comment thread task_02/src/stack.cpp
for (int i = 0; i < arr.size(); ++i) {
std::cout << arr[i] << " ";
}
std::cout << std::endl;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not use 'std::endl' with streams; use '\n' instead [performance-avoid-endl]

Suggested change
std::cout << std::endl;
std::cout << '\n';

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

Comment thread task_01/src/test.cpp Outdated
#include "two_numbers.h"

// Вспомогательная функция для перехвата вывода
std::string captureOutput(std::vector<int>& numbers, int len, int target) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: function 'captureOutput' can be made static or moved into an anonymous namespace to enforce internal linkage [misc-use-internal-linkage]

Suggested change
std::string captureOutput(std::vector<int>& numbers, int len, int target) {
для перехвата выводаstatic

Comment thread task_01/src/test.cpp Outdated
s
FindSum(numbers, len, target);

std::cout.rdbuf(old);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: unknown type name 's' [clang-diagnostic-error]

));
    ^

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

Comment thread task_01/src/test.cpp Outdated
#include "two_numbers.h"

// Вспомогательная функция для перехвата вывода
static std::string captureOutput(std::vector<int>& numbers, int len, int target) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: function 'captureOutput' declared 'static', move to anonymous namespace instead [misc-use-anonymous-namespace]

 для перехвата вывода
                                                           ^

Comment thread task_07/src/main.cpp Outdated
int main() { return 0; }
#include "tree.hpp"

static void printTreeInfo(const BinarySearchTree& bst) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: function 'printTreeInfo' declared 'static', move to anonymous namespace instead [misc-use-anonymous-namespace]

static void printTreeInfo(const BinarySearchTree& bst) {
            ^

Comment thread task_07/src/tree.cpp Outdated
}

int BinarySearchTree::minValue() const {
if (!root) throw std::runtime_error("Tree is empty");
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no member named 'runtime_error' in namespace 'std' [clang-diagnostic-error]

  if (!root) throw std::runtime_error("Tree is empty");
                        ^

Comment thread task_01/src/two_numbers.h Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

переименуй файл в .hpp

Comment thread task_01/src/two_numbers.h Outdated
@@ -0,0 +1,3 @@
#include <vector>

void FindSum(std::vector<int>& numbers, int len, int target);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

функция что-то находит, а где результат непонятно

и в тестах пришлось что-то хитрое придумывать, проще вернуть структуру или пару

Comment thread task_02/src/stack.cpp Outdated
#include <stdexcept>

void Stack::Push(int value) { data_.push(value); }
void Stack::push(int element) { arr.push_back(element); }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Push

Comment thread task_02/src/stack.cpp Outdated
if (arr.empty()) {
throw std::out_of_range("Stack is empty. Cannot find min.");
}
return *std::min_element(arr.begin(), arr.end());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тут должна быть сложность О(1), а не О(N)

Comment thread task_03/src/topology_sort.hpp Outdated
#pragma once
#include <vector>

std::vector<int> TopologySort(const std::vector<int>& temperatures); No newline at end of file
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

имя функции другое нудно дать

Comment thread task_04/src/test.cpp
TEST(TopologySort, Simple) {
ASSERT_EQ(1, 1); // Stack []
}
TEST(TopologySort, Simple) { ASSERT_EQ(1, 1); }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а другие тесты

Comment thread task_07/src/tree.hpp Outdated
@@ -0,0 +1,32 @@
#include <memory>

class BinarySearchTree {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

обычное дерево, не сбалансированое(

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

Comment thread task_07/src/test.cpp Outdated
ASSERT_EQ(1, 1); // Stack []
class AVLTreeTest : public ::testing::Test {
protected:
AVLTree tree;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: member variable 'tree' has protected visibility [cppcoreguidelines-non-private-member-variables-in-classes]

    AVLTree tree;
            ^

Comment thread task_07/src/tree.hpp Outdated
void clear() { clear(root); root = nullptr; }

private:
Node* root;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: use default member initializer for 'root' [cppcoreguidelines-use-default-member-init]

task_07/src/tree.hpp:11:

-     AVLTree() : root(nullptr) {}
+     AVLTree() : {}
Suggested change
Node* root;
Node* root{nullptr};

Comment thread task_07/src/tree.hpp Outdated
void clear(Node* node);

// Вспомогательные функции
int height(Node* node) { return node ? node->height : 0; }
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: Undefined or garbage value returned to caller [clang-analyzer-core.uninitialized.UndefReturn]

ные функции
                                                   ^
Additional context

task_07/src/tree.cpp:3: Assuming 'node' is non-null

    if (!node) return new Node{key, nullptr, nullptr, 1};
        ^

task_07/src/tree.cpp:3: Taking false branch

    if (!node) return new Node{key, nullptr, nullptr, 1};
    ^

task_07/src/tree.cpp:5: Assuming 'key' is < field 'key'

    if (key < node->key)
        ^

task_07/src/tree.cpp:5: Taking true branch

    if (key < node->key)
    ^

task_07/src/tree.cpp:6: Calling 'AVLTree::insert'

        node->left = insert(node->left, key);
                     ^

task_07/src/tree.cpp:3: Assuming 'node' is null

    if (!node) return new Node{key, nullptr, nullptr, 1};
        ^

task_07/src/tree.cpp:3: Taking true branch

    if (!node) return new Node{key, nullptr, nullptr, 1};
    ^

task_07/src/tree.cpp:3: Uninitialized value stored to field 'height'

    if (!node) return new Node{key, nullptr, nullptr, 1};
                      ^

task_07/src/tree.cpp:6: Returning from 'AVLTree::insert'

        node->left = insert(node->left, key);
                     ^

task_07/src/tree.cpp:15: Calling 'AVLTree::balance'

n balance(node);
  ^

task_07/src/tree.cpp:69: Calling 'AVLTree::updateHeight'

updateHeight(node);
^

task_07/src/tree.hpp:30: Calling 'AVLTree::height'

t(node->right) : 0; }
                                                                                      ^

task_07/src/tree.hpp:28: 'node' is non-null

ные функции
                                                          ^

task_07/src/tree.hpp:28: '?' condition is true

ные функции
                                                          ^

task_07/src/tree.hpp:28: Undefined or garbage value returned to caller

ные функции
                                                   ^

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

Comment thread task_07/src/test.cpp

class AVLTreeTest : public ::testing::Test {
protected:
AVLTree tree;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: member variable 'tree' has protected visibility [cppcoreguidelines-non-private-member-variables-in-classes]

  AVLTree tree;
          ^

Comment thread task_07/src/tree.hpp
}

private:
Node* root;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: use default member initializer for 'root' [cppcoreguidelines-use-default-member-init]

task_07/src/tree.hpp:11:

-   AVLTree() : root(nullptr) {}
+   AVLTree() : {}
Suggested change
Node* root;
Node* root{nullptr};

Comment thread task_07/src/tree.hpp
void clear(Node* node);

// Вспомогательные функции
int height(Node* node) { return node ? node->height : 0; }
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: Undefined or garbage value returned to caller [clang-analyzer-core.uninitialized.UndefReturn]

ные функции
                                                 ^
Additional context

task_07/src/tree.cpp:3: Assuming 'node' is non-null

  if (!node) return new Node{key, nullptr, nullptr, 1};
      ^

task_07/src/tree.cpp:3: Taking false branch

  if (!node) return new Node{key, nullptr, nullptr, 1};
  ^

task_07/src/tree.cpp:5: Assuming 'key' is < field 'key'

  if (key < node->key)
      ^

task_07/src/tree.cpp:5: Taking true branch

  if (key < node->key)
  ^

task_07/src/tree.cpp:6: Calling 'AVLTree::insert'

    node->left = insert(node->left, key);
                 ^

task_07/src/tree.cpp:3: Assuming 'node' is null

  if (!node) return new Node{key, nullptr, nullptr, 1};
      ^

task_07/src/tree.cpp:3: Taking true branch

  if (!node) return new Node{key, nullptr, nullptr, 1};
  ^

task_07/src/tree.cpp:3: Uninitialized value stored to field 'height'

  if (!node) return new Node{key, nullptr, nullptr, 1};
                    ^

task_07/src/tree.cpp:6: Returning from 'AVLTree::insert'

    node->left = insert(node->left, key);
                 ^

task_07/src/tree.cpp:15: Calling 'AVLTree::balance'

n balance(node);
  ^

task_07/src/tree.cpp:70: Calling 'AVLTree::updateHeight'

updateHeight(node);
^

task_07/src/tree.hpp:36: Calling 'AVLTree::height'

eHeight(Node* node) {
                                                      ^

task_07/src/tree.hpp:31: 'node' is non-null

ные функции
                                                        ^

task_07/src/tree.hpp:31: '?' condition is true

ные функции
                                                        ^

task_07/src/tree.hpp:31: Undefined or garbage value returned to caller

ные функции
                                                 ^

#include <utility>
#include <vector>

class FindSum {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а зачем тут класс?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants